 <?php
	include '../conn/islogin.php';
	include '../conn/conn.php';
?>
<!DOCTYPE html>
<html class="x-admin-sm">
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.1</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=1.0" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script type="text/javascript" src="../js/cookie.js"></script>
 <script type="text/javascript" charset="utf-8" src="../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="../ueditor/lang/zh-cn/zh-cn.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  
  <body>
    <div class="x-body">
        <form class="layui-form" action="" method="post">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>栏目：
              </label>
              <div class="layui-input-inline">
                  <select name="categoryNo" lay-verify="required">
                  	<option value="">...</option>
                  	<?php $category_sql = "select * from tb_category where type = 'list'";
						$category_result = mysqli_query($link, $category_sql);
						while ($category_info = mysqli_fetch_array(@$category_result)) {
                  	echo "<option value='". $category_info['categoryNo'] . "'>".$category_info['categoryName']."</option>";  } ?>
                 
                    <!--<option value="2">草稿</option>
                    <option value="3">回收站</option>
                    <option value="4">关闭</option>-->
                  </select>
              </div>
          </div>
             <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>新闻状态
              </label>
              <div class="layui-input-inline">
                  <select name="open" lay-verify="required">
                  	<option value="">选择状态</option>
                    <option value="1">启用</option>
                    <option value="2">草稿</option>
                    <option value="3">回收站</option>
                  </select>
              </div>
          </div>
			 <div class="layui-form-item">
              <label for="" class="layui-form-label">
                  <span class="x-red">*</span>是否置顶
              </label>
              <div class="layui-input-inline">
                  <select name="PlacedTop" lay-verify="required">
                <option value="0">否</option>
                    <option value="1">是</option>
                   
                  </select>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>标题：
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="title" name="title" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="keywords" class="layui-form-label">
                  <span class="x-red">*</span>关键词：
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="keywords" name="keywords" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="author" class="layui-form-label">
                  <span class="x-red">*</span>文章作者：
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="author" name="author" value="<?php echo $_SESSION['jsjgcxusername']; ?>"  required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
                  
                  <!--<input type="hidden"  name="publishTime"  value="<?php $time = gmdate("Y-m-d H:i:s", time() + 8 * 3600); echo$time; ?>" >-->
                  
              </div>
          </div>
                <div class="layui-form-item">
              <label for="clicked" class="layui-form-label">
                  <span class="x-red">*</span>阅读量：
              </label>
              <div class="layui-input-inline">
                  <input type="text"  name="clicked"   required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
       <div class="layui-form-item">
              <label for="keywords" class="layui-form-label">
                  <span class="x-red">*</span>预览图：
              </label>
                 <div class="layui-input-inline">
              <input type="file" name="NewsImg" id="inputfile">
   </div>
          </div>
          <div class="layui-form-item ">
              <label for="desc" class="layui-form-label">
                <span class="x-red">*</span>新闻内容
              </label>
              <div class="layui-input-block">
                <textarea id="body" name="body" style="display: none;"></textarea>
<script id="container" name="body" type="text/plain" style="width: 900px;height: 200px;">        
			</script>
<script type="text/javascript">
				var ue = UE.getEditor('container');
			</script>
              </div>
          </div>
          <!--<div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
                  描述
              </label>
              <div class="layui-input-block">
                  <textarea placeholder="请输入内容" id="desc" name="desc" class="layui-textarea"></textarea>
              </div>
          </div>-->
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <!--<button  class="layui-btn" lay-filter="add" lay-submit="">
                  增加
              </button>-->
						<input type="submit" name="NewsImg" value="添加" lay-filter="add" lay-submit=""  class="layui-btn"/>
              
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;


          //监听提交
          form.on('submit(add)', function(data){
            console.log(form); 
            //发异步，把数据提交给php
            $.post('News_AddJson.php',data.field,function(data){
			if(data.status){
  layer.alert(data.data, {icon: 6},function () {
                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
				}else{
				layer.msg(data.data, {time: 2000});
			}
		},'json');
		return false;
        });
          
          
        });
    </script>

  </body>

</html>
